<%--
  Created by IntelliJ IDEA.
  User: 86181
  Date: 2022/10/18
  Time: 9:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<!--头部-->
<div class="modal-header">
    <button class="close" data-dismiss="modal">&times;</button>
    <h3>修改用户</h3>
</div>
<form id="updateuser" class="form-horizontal">
    <!--身体-->
    <div class="modal-body">
        <div class="form-group">
            <label class="control-label col-md-2" for="loginid">用户账号:</label>
            <div class="col-md-10">
                <input type="hidden" id="id" name="id">
                <input type="text" id="loginid" name="loginid" class="form-control" placeholder="请输入角色名称" required>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2" for="password">用户密码:</label>
            <div class="col-md-10">
                <input type="text" id="password" name="password" class="form-control" placeholder="请输入角色编号" required>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">状态:</label>
            <div class="col-md-10">
                <input type="radio" value="0" name="status" checked>正常
                <input type="radio" value="1" name="status">禁用
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2" for="photopathh">图片路径:</label>
            <div class="col-md-10">
                <input type="file" name="photopathh" id="photopathh" readonly>
            </div>
        </div>

    </div>
    <!--底部-->
    <div class="modal-footer">
        <div>
            <input type="button" id="btn1" value="修改用户" class="btn btn-info col-md-2 col-md-offset-2">
            <input type="reset" value="重置" class="btn btn-success col-md-2 col-md-offset-3">
            <input type="button" value="关闭" class="btn btn-danger col-md-2 col-md-offset-1">
        </div>

    </div>
</form>

<script>
    $("#btn1").click(function () {
        var params={
            url: 'updateusers.action',
            type:'post',
            dataType: 'json',
            success:function (data) {
                alert(data.msg);
                if(data.code==1){
                    location.href="users.jsp";
                }else {
                    location.href="updateusers.jsp";
                }
            }
        }
        $("#updateuser").ajaxSubmit(params)
    })
    //加载数据
    $(function () {
        var id='${param.id}'
        alert(id)
        $.ajax({
            url:'querybyusersid.action/'+id,
            type:'post',
            dataType:'json',
            success:function (data) {
                console.log(data)
                $("#id").val(data.id);
                $("#loginid").val(data.loginid);
                $("#password").val(data.password);
                $("#status").val(data.status);
                $("#photopathh").val(data.photopath);
            }
        })
    })
</script>
</body>
</html>
